package com.atom.module.mvvm.adapter

import androidx.databinding.Observable
import androidx.databinding.ObservableBoolean

abstract class BooleanEvent : ObservableBoolean, Event<Boolean, Unit> {

    constructor(value: Boolean) : super(value)
    constructor() : super()
    constructor(vararg dependencies: Observable?) : super(*dependencies)

    init {
        this.addOnPropertyChangedCallback(object : Observable.OnPropertyChangedCallback() {
            override fun onPropertyChanged(sender: Observable?, propertyId: Int) {
                if (sender is ObservableBoolean) {
                    this@BooleanEvent.invoke(sender.get())
                }
            }
        })
    }
}
